#include <stdio.h>

int main()
{
    int i = 0;
    int m,m0,n,n0 = 0;
    scanf("%d %d",&m,&n);
    int arr1[m];
    int arr2[n];
    int arr[m+n];
    for (i = 0; i < m; i++)
    {
        scanf("%d",&arr1[i]);
    }
    for (i = 0; i < n; i++)
    {
        scanf("%d",&arr2[i]);
    }
    for (i = 0; i < m + n; i++)
    {
        if (m0 == m)
        {
            arr[i] = arr2[n0];
            n0++;

        }
        else if (n0 == n || arr1[m0] < arr2[n0])
        {
            arr[i] = arr1[m0];
            m0++;
        }
        else 
        {
            arr[i] = arr2[n0];
            n0++;

        }
        
    }
    for (i = 0; i < m + n ; i++)
    {
        printf("%d ",arr[i]);
    }

    return 0;
}
